/**
 * ©2013-2015 Alan L. Rights Reserved.
 */
package org.freedom.railhunter.model;

import java.io.Serializable;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;

/**
 *
 * @author Alan
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class QueryLeftNewDTO implements Serializable {
    
    public static final String DOUBLE_DASH = "--";
    public static final String ASTERISK = "*";
    public static final String HAVE = "有";
    public static final String NOT_HAVE = "无";
    
    // 车次
    @JsonProperty(value = "train_no")
    private String trainNo;
    
    // 车站列车代码
    @JsonProperty(value = "station_train_code")
    private String stationTrainCode;
    
    @JsonProperty(value = "start_station_telecode")
    private String startStationTelecode;
    
    @JsonProperty(value = "start_station_name")
    private String startStationName;
    
    @JsonProperty(value = "end_station_telecode")
    private String endStationTelecode;
    
    @JsonProperty(value = "end_station_name")
    private String endStationName;
    
    @JsonProperty(value = "from_station_telecode")
    private String fromStationTelecode;
    
    @JsonProperty(value = "from_station_name")
    private String fromStationName;
    
    @JsonProperty(value = "to_station_telecode")
    private String toStationTelecode;
    
    @JsonProperty(value = "to_station_name")
    private String toStationName;
    
    @JsonProperty(value = "start_time")
    private String startTime;
    
    @JsonProperty(value = "arrive_time")
    private String arriveTime;
    
    @JsonProperty(value = "day_difference")
    private String dayDifference;
    
    @JsonProperty(value = "train_class_name")
    private String trainClassName;
    
    // 历时
    private String lishi;
    
    private String canWebBuy;
    
    private String lishiValue;
    
    @JsonProperty(value = "yp_info")
    private String ypInfo;
    
    @JsonProperty(value = "control_train_day")
    private String controlTrainDay;
    
    @JsonProperty(value = "start_train_date")
    private String startTrainDate;
    
    @JsonProperty(value = "seat_feature")
    private String seatFeature;
    
    @JsonProperty(value = "yp_ex")
    private String ypEx;
    
    @JsonProperty(value = "train_seat_feature")
    private String trainSeatFeature;
    
    @JsonProperty(value = "seat_types")
    private String seatTypes;
    
    @JsonProperty(value = "location_code")
    private String locationCode;
    
    @JsonProperty(value = "from_station_no")
    private String fromStationNo;
    
    @JsonProperty(value = "to_station_no")
    private String toStationNo;
    
    @JsonProperty(value = "control_day")
    private Integer controlDay;
    
    @JsonProperty(value = "sale_time")
    private String saleTime;
    
    @JsonProperty(value = "is_support_card")
    private String isSupportCard;
    
    @JsonProperty(value = "gg_num")
    private String ggNum;
    
    // 高级软卧数量
    @JsonProperty(value = "gr_num")
    private String grNum;
    
    // 其他数量
    @JsonProperty(value = "qt_num")
    private String qtNum;
    
    // 软卧数量
    @JsonProperty(value = "rw_num")
    private String rwNum;
    
    // 软座数量
    @JsonProperty(value = "rz_num")
    private String rzNum;
    
    // 特等座数量
    @JsonProperty(value = "tz_num")
    private String tzNum;
    
    // 无座数量
    @JsonProperty(value = "wz_num")
    private String wzNum;
    
    @JsonProperty(value = "yb_num")
    private String ybNum;
    
    // 硬卧数量
    @JsonProperty(value = "yw_num")
    private String ywNum;
    
    // 硬座数量
    @JsonProperty(value = "yz_num")
    private String yzNum;
    
    // 二等座数量
    @JsonProperty(value = "ze_num")
    private String zeNum;
    
    // 一等座数量
    @JsonProperty(value = "zy_num")
    private String zyNum;
    
    // 商务座数量
    @JsonProperty(value = "swz_num")
    private String swzNum;

    public String getTrainNo() {
        return trainNo;
    }

    public void setTrainNo(String trainNo) {
        this.trainNo = trainNo;
    }

    public String getStationTrainCode() {
        return stationTrainCode;
    }

    public void setStationTrainCode(String stationTrainCode) {
        this.stationTrainCode = stationTrainCode;
    }

    public String getStartStationTelecode() {
        return startStationTelecode;
    }

    public void setStartStationTelecode(String startStationTelecode) {
        this.startStationTelecode = startStationTelecode;
    }

    public String getStartStationName() {
        return startStationName;
    }

    public void setStartStationName(String startStationName) {
        this.startStationName = startStationName;
    }

    public String getEndStationTelecode() {
        return endStationTelecode;
    }

    public void setEndStationTelecode(String endStationTelecode) {
        this.endStationTelecode = endStationTelecode;
    }

    public String getEndStationName() {
        return endStationName;
    }

    public void setEndStationName(String endStationName) {
        this.endStationName = endStationName;
    }

    public String getFromStationTelecode() {
        return fromStationTelecode;
    }

    public void setFromStationTelecode(String fromStationTelecode) {
        this.fromStationTelecode = fromStationTelecode;
    }

    public String getFromStationName() {
        return fromStationName;
    }

    public void setFromStationName(String fromStationName) {
        this.fromStationName = fromStationName;
    }

    public String getToStationTelecode() {
        return toStationTelecode;
    }

    public void setToStationTelecode(String toStationTelecode) {
        this.toStationTelecode = toStationTelecode;
    }

    public String getToStationName() {
        return toStationName;
    }

    public void setToStationName(String toStationName) {
        this.toStationName = toStationName;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getArriveTime() {
        return arriveTime;
    }

    public void setArriveTime(String arriveTime) {
        this.arriveTime = arriveTime;
    }

    public String getDayDifference() {
        return dayDifference;
    }

    public void setDayDifference(String dayDifference) {
        this.dayDifference = dayDifference;
    }

    public String getTrainClassName() {
        return trainClassName;
    }

    public void setTrainClassName(String trainClassName) {
        this.trainClassName = trainClassName;
    }

    public String getLishi() {
        return lishi;
    }

    public void setLishi(String lishi) {
        this.lishi = lishi;
    }

    public String getCanWebBuy() {
        return canWebBuy;
    }

    public void setCanWebBuy(String canWebBuy) {
        this.canWebBuy = canWebBuy;
    }

    public String getLishiValue() {
        return lishiValue;
    }

    public void setLishiValue(String lishiValue) {
        this.lishiValue = lishiValue;
    }

    public String getYpInfo() {
        return ypInfo;
    }

    public void setYpInfo(String ypInfo) {
        this.ypInfo = ypInfo;
    }

    public String getControlTrainDay() {
        return controlTrainDay;
    }

    public void setControlTrainDay(String controlTrainDay) {
        this.controlTrainDay = controlTrainDay;
    }

    public String getStartTrainDate() {
        return startTrainDate;
    }

    public void setStartTrainDate(String startTrainDate) {
        this.startTrainDate = startTrainDate;
    }

    public String getSeatFeature() {
        return seatFeature;
    }

    public void setSeatFeature(String seatFeature) {
        this.seatFeature = seatFeature;
    }

    public String getYpEx() {
        return ypEx;
    }

    public void setYpEx(String ypEx) {
        this.ypEx = ypEx;
    }

    public String getTrainSeatFeature() {
        return trainSeatFeature;
    }

    public void setTrainSeatFeature(String trainSeatFeature) {
        this.trainSeatFeature = trainSeatFeature;
    }

    public String getSeatTypes() {
        return seatTypes;
    }

    public void setSeatTypes(String seatTypes) {
        this.seatTypes = seatTypes;
    }

    public String getLocationCode() {
        return locationCode;
    }

    public void setLocationCode(String locationCode) {
        this.locationCode = locationCode;
    }

    public String getFromStationNo() {
        return fromStationNo;
    }

    public void setFromStationNo(String fromStationNo) {
        this.fromStationNo = fromStationNo;
    }

    public String getToStationNo() {
        return toStationNo;
    }

    public void setToStationNo(String toStationNo) {
        this.toStationNo = toStationNo;
    }

    public Integer getControlDay() {
        return controlDay;
    }

    public void setControlDay(Integer controlDay) {
        this.controlDay = controlDay;
    }

    public String getSaleTime() {
        return saleTime;
    }

    public void setSaleTime(String saleTime) {
        this.saleTime = saleTime;
    }

    public String getIsSupportCard() {
        return isSupportCard;
    }

    public void setIsSupportCard(String isSupportCard) {
        this.isSupportCard = isSupportCard;
    }

    public String getGgNum() {
        return ggNum;
    }

    public void setGgNum(String ggNum) {
        this.ggNum = ggNum;
    }

    public String getGrNum() {
        return grNum;
    }

    public void setGrNum(String grNum) {
        this.grNum = grNum;
    }

    public String getQtNum() {
        return qtNum;
    }

    public void setQtNum(String qtNum) {
        this.qtNum = qtNum;
    }

    public String getRwNum() {
        return rwNum;
    }

    public void setRwNum(String rwNum) {
        this.rwNum = rwNum;
    }

    public String getRzNum() {
        return rzNum;
    }

    public void setRzNum(String rzNum) {
        this.rzNum = rzNum;
    }

    public String getTzNum() {
        return tzNum;
    }

    public void setTzNum(String tzNum) {
        this.tzNum = tzNum;
    }

    public String getWzNum() {
        return wzNum;
    }

    public void setWzNum(String wzNum) {
        this.wzNum = wzNum;
    }

    public String getYbNum() {
        return ybNum;
    }

    public void setYbNum(String ybNum) {
        this.ybNum = ybNum;
    }

    public String getYwNum() {
        return ywNum;
    }

    public void setYwNum(String ywNum) {
        this.ywNum = ywNum;
    }

    public String getYzNum() {
        return yzNum;
    }

    public void setYzNum(String yzNum) {
        this.yzNum = yzNum;
    }

    public String getZeNum() {
        return zeNum;
    }

    public void setZeNum(String zeNum) {
        this.zeNum = zeNum;
    }

    public String getZyNum() {
        return zyNum;
    }

    public void setZyNum(String zyNum) {
        this.zyNum = zyNum;
    }

    public String getSwzNum() {
        return swzNum;
    }

    public void setSwzNum(String swzNum) {
        this.swzNum = swzNum;
    }
    
    public boolean isNumberMoreThan(String seatNumber, int number) {
        if (ASTERISK.equals(seatNumber)) {
            return false;
        }
        
        if (DOUBLE_DASH.equals(seatNumber)) {
            return false;
        }
        
        if (NOT_HAVE.equals(seatNumber)) {
            return false;
        }
        
        if (HAVE.equals(seatNumber)) {
            return true;
        }
        
        try {
            return Integer.parseInt(seatNumber) >= number;
        } catch (NumberFormatException e) {
            return false;
        }
    }
    
    public boolean isSeatNumberMoreThan(String seatTypeMark, int number) {
        switch (seatTypeMark) {
            case "ZY":
                return isNumberMoreThan(zyNum, number);
            case "ZE":
                return isNumberMoreThan(zeNum, number);
            case "SWZ":
                return isNumberMoreThan(swzNum, number);
            case "TZ":
                return isNumberMoreThan(tzNum, number);
            case "YZ":
                return isNumberMoreThan(yzNum, number);
            case "RZ":
                return isNumberMoreThan(rzNum, number);
            case "YW":
                return isNumberMoreThan(ywNum, number);
            case "RW":
                return isNumberMoreThan(rwNum, number);
            case "GR":
                return isNumberMoreThan(grNum, number);
            case "WZ":
                return isNumberMoreThan(wzNum, number);
        }
        return false;
    }
    
    public SeatType getSeatTypeNumberMoreThan(int number) {
        if (isNumberMoreThan(zyNum, number)) {
            return SeatType.YI_DENG_ZUO;
        } else if (isNumberMoreThan(zeNum, number)) {
            return SeatType.ER_DENG_ZUO;
        } else if (isNumberMoreThan(swzNum, number)) {
            return SeatType.SHANG_WU_ZUO;
        } else if (isNumberMoreThan(tzNum, number)) {
            return SeatType.TE_TENG_ZUO;
        } else if (isNumberMoreThan(yzNum, number)) {
            return SeatType.YING_ZUO;
        } else if (isNumberMoreThan(rzNum, number)) {
            return SeatType.RUAN_ZUO;
        } else if (isNumberMoreThan(ywNum, number)) {
            return SeatType.YING_WO;
        } else if (isNumberMoreThan(rwNum, number)) {
            return SeatType.RUAN_WO;
         } else if (isNumberMoreThan(grNum, number)) {
             return SeatType.GAO_JI_RUAN_WO;
        } else if ( isNumberMoreThan(wzNum, number)) {
            return SeatType.WU_ZUO;
        }
        return null;
    }

    @Override
    public String toString() {
        return "QueryLeftNewDTO{" + "trainNo=" + trainNo + ", stationTrainCode=" + stationTrainCode + ", startStationTelecode=" + startStationTelecode + ", startStationName=" + startStationName + ", endStationTelecode=" + endStationTelecode + ", endStationName=" + endStationName + ", fromStationTelecode=" + fromStationTelecode + ", fromStationName=" + fromStationName + ", toStationTelecode=" + toStationTelecode + ", toStationName=" + toStationName + ", startTime=" + startTime + ", arriveTime=" + arriveTime + ", dayDifference=" + dayDifference + '}';
    }
}
